package web

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func GetCourseDetail01(c *gin.Context) {
	//获取参数方式
	id := c.Param("id")
	name := c.Query("name")
	fmt.Println(id, name)
	c.JSON(http.StatusOK, gin.H{
		"id":   id,
		"name": name,
	})

}
func GetCourseVideo01(c *gin.Context) {

}
func AddCourse01(c *gin.Context) {

}
func PublishCourse01(c *gin.Context) {

}
func UploadCourse01(c *gin.Context) {
	//单文件上传
	file, _ := c.FormFile("file")
	c.SaveUploadedFile(file, "/upload/"+file.Filename)
	c.JSON(http.StatusOK, gin.H{
		"file_name": file.Filename,
	})
	//多文件上传
	form, _ := c.MultipartForm()
	files := form.File["files"]
	list := make([]string, len(files))
	for i, file := range files {
		c.SaveUploadedFile(file, "upload2"+file.Filename)
		list[i] = file.Filename
	}
	c.JSON(http.StatusOK, gin.H{
		"files": list,
	})
}
